package Eyjafjalla.power;

import Eyjafjalla.action.MakeTempCardInCloudAction;
import Eyjafjalla.card.status.Cloud_Eyjafjalla;
import com.badlogic.gdx.graphics.g2d.TextureAtlas;
import com.megacrit.cardcrawl.actions.common.ApplyPowerAction;
import com.megacrit.cardcrawl.actions.common.RemoveSpecificPowerAction;
import com.megacrit.cardcrawl.cards.DamageInfo;
import com.megacrit.cardcrawl.characters.AbstractPlayer;
import com.megacrit.cardcrawl.core.AbstractCreature;
import com.megacrit.cardcrawl.core.CardCrawlGame;
import com.megacrit.cardcrawl.helpers.ImageMaster;
import com.megacrit.cardcrawl.localization.PowerStrings;

public class GiveRedCloudPower extends AbstractEyjafjallaPower {
    public static final String POWER_ID = "eyjafjalla:GiveRedCloudPower";
    private static final PowerStrings powerStrings;

    public GiveRedCloudPower(AbstractCreature owner, int amount){
        this.name = powerStrings.NAME;
        this.ID = POWER_ID;
        this.owner = owner;
        this.amount = amount;
        this.updateDescription();
        String path128 = "EyjafjallaResources/img/power/GiveRedCloudPower_84.png";
        String path48 = "EyjafjallaResources/img/power/GiveRedCloudPower_32.png";
        this.region128 = new TextureAtlas.AtlasRegion(ImageMaster.loadImage(path128),0,0,84,84);
        this.region48 = new TextureAtlas.AtlasRegion(ImageMaster.loadImage(path48),0,0,32,32);
        this.isTurnBased = true;
        this.type = PowerType.BUFF;
    }

    @Override
    public int onAttacked(DamageInfo info, int damageAmount) {
        if(info.type== DamageInfo.DamageType.NORMAL){
            if(this.amount>0&&info.owner!=null){
                this.amount--;
                this.flash();
                addToBot(new ApplyPowerAction(info.owner,this.owner,new RedCloudPower(info.owner,1),1));
                if(this.amount<=0)
                    addToTop(new RemoveSpecificPowerAction(this.owner,this.owner,this));
                updateDescription();
            }
        }
        return super.onAttacked(info, damageAmount);
    }

    @Override
    public void updateDescription() {
        this.description = powerStrings.DESCRIPTIONS[0] + this.amount + powerStrings.DESCRIPTIONS[1];
    }

    static {
        powerStrings = CardCrawlGame.languagePack.getPowerStrings(POWER_ID);
    }
}



